package cn.tradewin.advisor.pages.master;

import org.apache.tapestry5.annotations.Log;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.slf4j.Logger;

import cn.tradewin.advisor.persist.model.Codetable;
import cn.tradewin.advisor.persist.services.CodetableService;

public class AddCode {

	@Property
	private Codetable codetable;

	@Inject
	private Logger log;

	@Inject
	private CodetableService codetableService;

	@Log
	void onPrepare() throws Exception {
		if (codetable == null) {
			codetable = new Codetable();
		}
	}

	@Log
	Object onSubmit() {
		try {
			codetableService.addCategory(codetable);
		} catch (Exception e) {
			log.debug(e.getMessage());
		}
		return CodeBoard.class;
	}
}
